package com.project.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.project.bean.VendorBean;
import com.project.service.IVendorService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("vendor")
public class VendorController {
    @Autowired
    private IVendorService service;

    @RequestMapping("findByItem")
    public IPage<VendorBean> findByItem(Integer pageNO, String name, String ranges) {
        return service.findByItem(pageNO, name, ranges);
    }

    @RequestMapping("findById")
    public VendorBean findById(Integer vendorId) {
        return service.findById(vendorId);
    }

    @RequestMapping("updateVendor")
    public String updateVendor(Integer vendorId, String headerName, String headerPhone) {
        service.updateVendor(vendorId, headerName, headerPhone);
        return "ok";
    }

    @RequestMapping("addVendor")
    public String addVendor(VendorBean vendor) {
        service.addVendor(vendor);
        return "ok";
    }

    @RequestMapping("findAll")
    public List<VendorBean> findAll() {
        return service.findAll();
    }
}
